//------------------------------------------------------------------------------
//
//   Go4Flex 
//   Copyright 2010 
//   All rights reserved. 
//
//------------------------------------------------------------------------------

package com.go4flex.usermanager.usercontrol.business
{
	import com.go4flex.usermanager.usercontrol.model.UserControlModel;

	import flash.events.IEventDispatcher;

	import mx.collections.ArrayCollection;
	import mx.controls.Alert;

	public class UserControlManager
	{

		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------

		public var model:UserControlModel;
		public var dispatcher:IEventDispatcher;

		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------

		public function usersListComplete(resultData:Object):void
		{
			if (resultData is Array)
			{
				model.usersList = new ArrayCollection(resultData as Array);
			}
			else
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function groupsListComplete(resultData:Object):void
		{
			if (resultData is Array)
			{
				model.groupsList = new ArrayCollection(resultData as Array);
			}
			else
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function permissionsListComplete(resultData:Object):void
		{
			if (resultData is Array)
			{
				model.permissionsList = new ArrayCollection(resultData as Array);
			}
			else
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function addNewUserComplete(resultData:Object):void
		{
			if (resultData is String)
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function deleteUserComplete(resultData:Object):void
		{
			if (resultData is String)
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function updateUserComplete(resultData:Object):void
		{
			if (resultData is String)
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function addNewGroupComplete(resultData:Object):void
		{
			if (resultData is String)
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function deleteGroupComplete(resultData:Object):void
		{
			if (resultData is String)
			{
				Alert.show(resultData as String, "Error");
			}
		}

		public function updateGroupComplete(resultData:Object):void
		{
			if (resultData is String)
			{
				Alert.show(resultData as String, "Error");
			}
		}

	}
}